package com.crm.system.controller.customerManager;

import com.crm.common.model.DataResponse;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.vo.customerManager.CustomerFollowVO;
import com.crm.system.service.customerManager.CustomerStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 客户数据指标统计页面数据
 * @Author renshaorong
 * @Date 2021/04/27 4:44 下午
 */
@RestController
@RequestMapping("/customerStatistics")
@Slf4j
public class CustomerStatisticsController {

    @Autowired
    private CustomerStatisticsService customerStatisticsService;

    /**
     * 折线图数据
     * @param dateUnit
     * @return
     */
    @PostMapping("getPolyLine")
    public DataResponse getPolyLine(@RequestParam("dateUnit") Integer dateUnit){
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),customerStatisticsService.getPolyLine(dateUnit));
    }

    /**
     * 柱状图数据
     * @return
     */
    @PostMapping("getCustomerBusiness")
    public DataResponse getCustomerBusiness(){
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),customerStatisticsService.getCustomerBusiness());
    }

    /**
     * 客户跟进意向值
     * @param request
     * @param type
     * @param dateUnit
     * @return
     */
    @PostMapping("getCustomerFollow")
    public DataResponse getCustomerFollow(HttpServletRequest request,
                                         @RequestParam(value = "type",required = false) Integer type,
                                         @RequestParam(value = "dateUnit",required = false) Integer dateUnit
    ){
        List<CustomerFollowVO> CustomerFollowVOList = customerStatisticsService.getCustomerFollow(type,dateUnit);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),CustomerFollowVOList);
    }

    /**
     * 地图数据
     * @return
     */
    @PostMapping("getMapData")
    public DataResponse getMapData(){
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),customerStatisticsService.getMapData());
    }
}
